package com.qzsf.backend.exception;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/10/31 9:44 周四
 * @Email 1429278462@qq.com
 * @Remark 全局异常处理
 * @Version 1.0
 */
import com.qzsf.backend.common.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e){
        e.printStackTrace();
        return Result.error(StringUtils.hasLength(e.getMessage())?e.getMessage():"操作失败");
    }
}
